Skip to content

First version of the X-ARAPUCAs decoder (V1740B digitizers) - #552

Merged
bear-is-asleep merged 22 commits into
developfrom
feature/aliciavr_XARAPUCA_offline_decoder
Jan 24, 2025
Merged

First version of the X-ARAPUCAs decoder (V1740B digitizers)#552
bear-is-asleep merged 22 commits into
developfrom
feature/aliciavr_XARAPUCA_offline_decoder

Conversation

@aliciavr

@aliciavr aliciavr commented Nov 4, 2024

Copy link
Copy Markdown
Contributor

Description

Adds a first full version of the X-ARAPUCAs decoder (V1740B digitizers).

  • Accesses the ART-DAQ CAENV1740 fragments.
  • Implements the binary decoding of the waveforms per fragment: 64 waveforms per board.
  • Includes verbosity and several debugging options.
  • Supports multi-board execution (up to 4 boards).
  • The X axis considers the Trigger Time Stamp (TTT) in microseconds directly given by the headers.
  • Creates two output files: one with the waveforms in ROOT histograms and another where the products of this art::EDProducer, a vector of raw::OpDetWaveforms, are dumped.

More features may be added in the future:

  • Timing, trigger and clock functions.
  • Different layout between fragment, trigger and event features.

Checklist

  • Added at least 1 label from available labels.
  • Assigned at least 1 reviewer under Reviewers,
  • Assigned all contributers including yourself under Assignees
  • [N/A] Linked any relevant issues under Developement
  • [N/A] Does this PR affect CAF data format? If so, please assign a CAF maintainer (PetrilloAtWork or JosiePaton) as additional reviewer.
  • [N/A] Does this affect the standard workflow?

Relevant PR links (optional)

Does this PR require merging another PR in a different repository (such as sbnanobj/sbnobj etc.)? No

Link(s) to docdb describing changes (optional)

@aliciavr aliciavr added the pds Photon Detection System label Nov 4, 2024
@aliciavr aliciavr self-assigned this Nov 4, 2024
@aliciavr
aliciavr marked this pull request as ready for review November 27, 2024 15:29
@aliciavr

aliciavr commented Dec 2, 2024

Copy link
Copy Markdown
Contributor Author

@jicrespo @lynnt20 @tomjunk this PR is ready for review

@tomjunk tomjunk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Alicia -- sorry to be slow here! I didn't check all the logic of unpacking the raw waveforms -- I assume that's what the cout statements are there and also the two kinds of output, so you can test this decoder on data and tell whether it is doing its job. There are some things that could be optimized, such as reading the fragments straight out of the art event memory instead of copying them to a locally-owned vector called fragments, but as it goes out of scope at the end of the module, I won't fuss about it for getting this deployed. Copying data is actually a very quick operation on CPUs these days, but just allocating the memory, even temporarily, may raise the memory usage of a job. Of course if other modules use even more memory temporarily, this may not contribute to the high-water mark of a job. About how much data are there from X-ARAPUCAs per event? You can use product_sizes_dumper to find out.

One issue that may be bigger is the fact that it makes two copies of all the output. It makes OpDetWaveforms for the artROOT output file, but also TH1Ds for each waveform, saved into the TFileService output file (which may be named something other than decoder_hist.root, depending on the fcl config). Can you add a fcl parameter to steer the latter? In large data production campaigns, people probably won't look at every opdet waveform in the histogram files. So I'd imagine for production, we'd want to disable writing those TH1Ds anyway. But for debugging, you may want some of them, possibly not all. So a limit on how many you might want to save might be a good fcl parameter, as a signed integer. zero saves none, -1 saves them all, and n saves the first n of them. You can default that to -1, but I'll bet the production team would prefer 0.

// - A decoder_hist.root file gathering a waveform histograms.
std::stringstream hist_name("");
hist_name << "Event " << fevent_counter << " CH " << ch << " [frag " << f << ", board " << b << " (slot " << fboard_id_list[b] << ") ] waveform";
TH1D* hist = tfs->make<TH1D>(hist_name.str().c_str(), hist_name.str().c_str(), wvfms[ch].size(), TTT_ini_us, TTT_end_us);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these have to be TH1D's since they are filled with values from uint16_t's? D is a double-precision floating-point number, or 64 bits per bin. You could even use TH1I. TH1S may be too short, as you have unsigned 16-bit ints as input, and they might overflow a signed 16-bit int. But 64-bit floats are way overkill.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @tomjunk thank you so much for your comments! I have pushed 3 new commits: one for the N debug waveforms to be stored, another one for fixing the type of the TH1 object and a last one for reading and processing straight out the fragments.

@bear-is-asleep

Copy link
Copy Markdown
Contributor

@aliciavr @tomjunk I see there is some unresolved comments, can we get these addressed so the PR can be approved?

@aliciavr

Copy link
Copy Markdown
Contributor Author

@bear-is-asleep @tomjunk Sure! I am on it, I'll let you know as soon as I update the decoder with the new suggestions. Thank you for the comments!

@aliciavr
aliciavr requested a review from tomjunk January 11, 2025 14:51
@aliciavr

Copy link
Copy Markdown
Contributor Author

Regarding the product_sizes_dumper test I had the following output for a file from the stream Off Beam + Zero Bias and a Light Scan trigger configuration with 50 events:

Size on disk for the file: xarapucadecoder-art.root
Total size on disk: 1046972697

     Size in bytes   Fraction TTree/TKey Name
        1043104604      0.996 Events
           3838016      0.004 RootFileDB
              7835      0.000 EventMetaData
              3724      0.000 MetaData
              1386      0.000 SubRuns
              1363      0.000 Runs
               895      0.000 Parentage
               887      0.000 FileIndex
               560      0.000 SubRunMetaData
               548      0.000 RunMetaData
               515      0.000 ResultsMetaData
               501      0.000 ResultsTree
------------------------------
        1046960834      1.000 Total

Details for each TTree that occupies more than the fraction 0.05 of the size on disk.


Details for branch: Events

     Size in bytes   Fraction Data Product Name
         585176918      0.561 artdaq::Fragments_daq_NEVISTPC_DAQEVB01.
         417046175      0.400 artdaq::Fragments_daq_ContainerCAENV1730_DAQEVB01.
          16034277      0.015 artdaq::Fragments_daq_ContainerBERNCRTV2_DAQEVB01.
          15333491      0.015 artdaq::Fragments_daq_ContainerCAENV1740_DAQEVB01.
           9336433      0.009 raw::OpDetWaveforms_xarapucadecoder_XARAPUCAChannels_XARAPUCADecoder.
             93464      0.000 artdaq::Fragments_daq_ContainerPTB_DAQEVB01.
             26495      0.000 artdaq::Fragments_daq_ContainerTDCTIMESTAMP_DAQEVB01.
             16393      0.000 sbndaq::CRTmetric_crttriggerproducer__DAQEVB01.
              3060      0.000 artdaq::Fragments_daq_NEVISTB_DAQEVB01.
              2167      0.000 sbnd::trigger::pmtSoftwareTriggers_pmtmetricproducer__DAQEVB01.
              1907      0.000 artdaq::detail::RawEventHeader_daq_RawEventHeader_DAQEVB01.
              1377      0.000 art::TriggerResults_TriggerResults__DAQEVB01.
              1314      0.000 art::TriggerResults_TriggerResults__XARAPUCADecoder.
              1308      0.000 artdaq::Fragments_daq_ContainerICARUSTriggerUDP_DAQEVB01.
              1303      0.000 artdaq::Fragments_daq_ContainerICARUSTriggerV3_DAQEVB01.
              1303      0.000 artdaq::Fragments_daq_ContainerSPECTRATIMEVENT_DAQEVB01.
              1303      0.000 artdaq::Fragments_daq_ContainerICARUSTriggerV2_DAQEVB01.
              1298      0.000 artdaq::Fragments_daq_ContainerDUMMYGENERATOR_DAQEVB01.
              1294      0.000 artdaq::Fragments_daq_ContainerICARUSPMTGate_DAQEVB01.
              1293      0.000 artdaq::Fragments_daq_ContainerPHYSCRATEDATA_DAQEVB01.
              1293      0.000 artdaq::Fragments_daq_ContainerPHYSCRATESTAT_DAQEVB01.
              1282      0.000 artdaq::Fragments_daq_ContainerWhiteRabbit_DAQEVB01.
              1278      0.000 artdaq::Fragments_daq_ContainerBERNCRTZMQ_DAQEVB01.
              1272      0.000 artdaq::Fragments_daq_ContainerBottomCRT_DAQEVB01.
              1266      0.000 artdaq::Fragments_daq_ContainerNEVISTPC_DAQEVB01.
              1265      0.000 artdaq::Fragments_daq_ContainerContainer_DAQEVB01.
              1258      0.000 artdaq::Fragments_daq_ContainerInvalid_DAQEVB01.
              1258      0.000 artdaq::Fragments_daq_ContainerBERNCRT_DAQEVB01.
              1258      0.000 artdaq::Fragments_daq_ContainerNEVISTB_DAQEVB01.
              1258      0.000 artdaq::Fragments_daq_ContainerUNKNOWN_DAQEVB01.
              1257      0.000 artdaq::Fragments_daq_ICARUSTriggerUDP_DAQEVB01.
              1256      0.000 artdaq::Fragments_daq_ContainerMISSED_DAQEVB01.
              1256      0.000 artdaq::Fragments_daq_ICARUSTriggerV2_DAQEVB01.
              1256      0.000 artdaq::Fragments_daq_SPECTRATIMEVENT_DAQEVB01.
              1256      0.000 artdaq::Fragments_daq_ICARUSTriggerV3_DAQEVB01.
              1250      0.000 artdaq::Fragments_daq_ContainerEmpty_DAQEVB01.
              1248      0.000 artdaq::Fragments_daq_DUMMYGENERATOR_DAQEVB01.
              1245      0.000 artdaq::Fragments_daq_ContainerError_DAQEVB01.
              1243      0.000 artdaq::Fragments_daq_PHYSCRATEDATA_DAQEVB01.
              1243      0.000 artdaq::Fragments_daq_PHYSCRATESTAT_DAQEVB01.
              1243      0.000 artdaq::Fragments_daq_ICARUSPMTGate_DAQEVB01.
              1242      0.000 artdaq::Fragments_daq_ContainerData_DAQEVB01.
              1242      0.000 artdaq::Fragments_daq_TDCTIMESTAMP_DAQEVB01.
              1240      0.000 artdaq::Fragments_daq_unidentified_DAQEVB01.
              1238      0.000 artdaq::Fragments_daq_WhiteRabbit_DAQEVB01.
              1226      0.000 artdaq::Fragments_daq_BERNCRTZMQ_DAQEVB01.
              1225      0.000 artdaq::Fragments_daq_CAENV1740_DAQEVB01.
              1221      0.000 artdaq::Fragments_daq_Container_DAQEVB01.
              1216      0.000 artdaq::Fragments_daq_BottomCRT_DAQEVB01.
              1215      0.000 artdaq::Fragments_daq_Invalid_DAQEVB01.
              1215      0.000 artdaq::Fragments_daq_BERNCRTV2_DAQEVB01.
              1214      0.000 artdaq::Fragments_daq_CAENV1730_DAQEVB01.
              1214      0.000 artdaq::Fragments_daq_UNKNOWN_DAQEVB01.
              1212      0.000 artdaq::Fragments_daq_BERNCRT_DAQEVB01.
              1211      0.000 artdaq::Fragments_daq_MISSED_DAQEVB01.
              1202      0.000 artdaq::Fragments_daq_Error_DAQEVB01.
              1201      0.000 artdaq::Fragments_daq_Empty_DAQEVB01.
              1185      0.000 artdaq::Fragments_daq_Data_DAQEVB01.
              1183      0.000 artdaq::Fragments_daq_PTB_DAQEVB01.
              1142      0.000 EventAuxiliary
------------------------------
        1043132058      1.000 Total

@tomjunk tomjunk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! My comments have been addressed -- looks like the memory usage should be down by a lot, as it only copies one fragment at a time instead of them all, and the default is not to make a huge histogram output file in addition to the artROOT file, but you can get it if you want it. Very good!

@RachelCoackley

Copy link
Copy Markdown
Contributor

@aliciavr please would you be able to resolve the conflicts? Thanks!! :)

@aliciavr

Copy link
Copy Markdown
Contributor Author

Hi @RachelCoackley, conflicts resolved :)

@RachelCoackley

Copy link
Copy Markdown
Contributor

trigger build RachelCoackley/larreco>larreco@v09_93_01rachel LArSoft/lar*@LARSOFT_SUITE_v09_93_01 SBNSoftware/sbncode@v09_93_01_p02 SBNSoftware/sbnanaobj@bug/coackley_ciCafv09_91_02 SBNSoftware/sbndaq-artdaq-core@v1_10_03 SBNSoftware/sbnobj@v09_19_05

@FNALbuild

Copy link
Copy Markdown
Collaborator

✔️ CI build for LArSoft Succeeded on slf7 for e26:prof -- details available through the CI dashboard

@FNALbuild

Copy link
Copy Markdown
Collaborator

✔️ CI build for LArSoft Succeeded on slf7 for c14:prof -- details available through the CI dashboard

@FNALbuild

Copy link
Copy Markdown
Collaborator

❌ CI build for SBND Failed at phase build SBND on slf7 for c14:prof -- details available through the CI dashboard

🚨 For more details about the failed phase, check the build SBND phase logs

parent CI build details are available through the CI dashboard

@FNALbuild

Copy link
Copy Markdown
Collaborator

⚠️ CI build for SBND Warning at phase ci_tests SBND on slf7 for e26:prof - ignored failure for unit_test - ignored warnings for build -- details available through the CI dashboard

🚨 For more details about the warning phase, check the ci_tests SBND phase logs

parent CI build details are available through the CI dashboard

@bear-is-asleep

Copy link
Copy Markdown
Contributor

Approved

@RachelCoackley

Copy link
Copy Markdown
Contributor

No product size differences to confirm, ci_test warnings for nucosmics_caf_quick_test_sbndcode and single_caf_quick_test_sbndcode which can be ignored (they aren't related to this PR)

@bear-is-asleep
bear-is-asleep merged commit b50badc into develop Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pds Photon Detection System

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants